package com.spzx.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spzx.common.core.utils.StringUtils;
import com.spzx.product.api.domain.Brand;
import com.spzx.product.mapper.BrandMapper;
import com.spzx.product.service.BrandService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements BrandService {
    @Override
    public List<Brand> getPageList(String name) {
        //创建LambdaQueryWrapper对象
        LambdaQueryWrapper<Brand> brandLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //封装查询条件
        brandLambdaQueryWrapper.like(StringUtils.hasText(name),Brand::getName,name);
        //调用baseMapper中带条件查询的方法
        List<Brand> brandList = baseMapper.selectList(brandLambdaQueryWrapper);
        return brandList;
    }
}
